﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace MaxStoreErp.Core.Converters
{
    public class NullToBooleanConverter
        : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var inverse = (parameter as string) == "inverse";

            if (inverse)
            {
                return (value != null);
            }

            return (value == null);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}